a) Field of the Invention
The present invention relates to a method of overwriting nonvolatile memory data and a control apparatus used for the method. More specifically, the present invention relates to a method of overwriting data in such a way that data saved in nonvolatile memory is protected and a control apparatus is used for the method.
b) Description of the Related Art
Lately, flash memory capacity has increased dramatically along with an exponential improvement in useable lifetime in terms of the number of times data in flash memory can be overwritten. By these advances, flash memory serves not only as the conventional coding program storage (medium), being overwritten less frequently, but also as nonvolatile memory, being overwritten very frequently.
Flash memory has a unique property that affects the overwriting method: when one wants to write the bit data “1” over “0”, one must first erase all data in a sector to which the data to be overwritten (in logic, the target bit data is set to “1”). It is impossible to pin-pointedly erase data in a sector. For this reason, flash memory data is conventionally overwritten in the following manner (See FIG. 4).
First of all, prior to complete erasure of data in a sector containing data to be overwritten, a work area mapped in volatile memory such as random access memory (hereafter referred to as RAM) is prepared; data within the range to be erased is copied for security (Step 101, S101). Then, the data to be overwritten (edited) is overwritten (edited) in the work area (Step 102, S102). The corresponding sector in flash memory is erased (Step 103, S103). The post-overwrite data on the work area is written in the erased sector (Step 104, S104). Overwriting is thus completed.
However, erasing flash memory often requires erasure of entire data in a sector at first, requiring relatively long process time (e.g. seconds) compared to other processes. The sector size of flash memory varies from multiples of ten bits to multiples of 10,000 bits depending on the product type. Some types of flash memory take about 15 seconds from start to completion of erasure.
For this reason, an interruption of power supply, if it occurs unexpectedly between the erasure of data in flash memory and the completion of writing the post-overwrite data, interrupts control of flash memory, causing loss of data saved on RAM, volatile memory; one may be seriously concerned with irrevocable loss of very important data.
Conventionally, to overcome this problem, a power interruption detection circuit, and a backup power supply, supplying auxiliary power at the time of complete power outage, have been employed.
Problems the Present Invention Intends to Solve
Nonetheless, addition of a hardware device such as a backup power supply, if it is installed to protect important data in flash memory from power outage, increases the cost of manufacturing the product of interest. In addition, installing a backup power supply on a product of interest, so as to sufficiently complement the maximum value required for the duration of erasure of flash memory, may require modification of the shape of a product of interest. Moreover, if a battery is utilized as a backup power (hardware prevention measure) supply during power outage, power will not be supplied if the battery is not sufficiently charged. The use of a battery thus requires another mechanism for sensing whether the battery is charged well in advance.